home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST9-26.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  936b  |  42 lines

  1. ;
  2. ; *** Listing 9-26 ***
  3. ;
  4. ; Performs addition of the ASCII decimal value "00001"
  5. ; to an ASCII decimal count variable.
  6. ;
  7. DECIMAL_INCREMENT    macro
  8.     local    DigitLoop
  9.     std        ;we'll work from least-significant
  10.             ; to most-significant
  11.     mov    si,offset ASCIIOne+VALUE_LENGTH-1
  12.     mov    di,offset Count+VALUE_LENGTH-1
  13.     mov    ax,ds
  14.     mov    es,ax    ;ES:DI points to Count for STOSB
  15.     mov    cx,VALUE_LENGTH
  16.     clc        ;there's no carry into the least-
  17.             ; significant digit
  18. DigitLoop:
  19.     lodsb        ;get the next increment digit
  20.     adc    al,[di]    ;add it to the next Count digit
  21.     aaa        ;adjust to an unpacked BCD digit
  22.     lahf        ;save the carry, in case we just
  23.             ; turned over 9
  24.     add    al,'0'    ;make it an ASCII digit
  25.     stosb
  26.     sahf        ;get back the carry for the next adc
  27.     loop    DigitLoop
  28.     endm
  29. ;
  30.     jmp    Skip
  31. ;
  32. Count    db    '00000'
  33. VALUE_LENGTH    equ    $-Count
  34. ASCIIOne db    '00001'
  35. ;
  36. Skip:
  37.     call    ZTimerOn
  38.     rept    100
  39.     DECIMAL_INCREMENT
  40.     endm
  41.     call    ZTimerOff
  42.